import os
import sys


# 请在此输入您的代码
w = int(input())
n = int(input())
x = (w+n)%7
if x == 0 :
    x = 7
print(x)
